package game.objects.weapons.projectiles 
{
	import flash.geom.Point;
	import game.core.CollisionTypes;
	import game.objects.Building;
	import game.objects.weapons.Weapon;
	import net.flashpunk.Entity;
	/**
	 * ...
	 * @author rnk
	 */
	public class Projectile extends Entity
	{
		public var weapon:Weapon;
		
		public var velocity:Point = new Point();
		public var mass:Number = 1.0;
		
		public function Projectile() 
		{
			type = CollisionTypes.weapon;
		}
		
		override public function update():void 
		{
			x += velocity.x;
			y += velocity.y;
			
			velocity.x += weapon.tower.gameManager.wind / mass;
			velocity.y += weapon.tower.gameManager.gravity;
			
			UpdateCollisions();
		}
		
		protected function UpdateCollisions():void
		{
			var collEnt:Entity = collide(CollisionTypes.ground,x,y);
			if (collEnt)
			{
				Hit(null);
			}
		}
		
		public function Hit(target:Building):void
		{
			Die();
		}
		
		public function Die():void
		{
			world.remove(this);
			
		}
		
	}

}